package com.han.facade;

/**
 * @ClassName SmartApplicationFacade
 * @Description 外观类，用户主要和该类对象进行交互
 * @Author duoduo Han
 * @Date 2024/6/12 15:48
 */
public class SmartApplicationFacade {
    //聚合电灯、电视、空调对象
    private Light light;
    private TV tv;
    private AirCondition airCondition;

    public SmartApplicationFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }
    //通过语音控制
    public void say(String message){
        if(message.contains("打开")){
            on();
        }else if(message.contains("关闭")){
            off();
        }else {
            System.out.println("听不懂听不懂");
        }
    }
    private void on() {
        light.on();
        tv.on();
        airCondition.on();
    }
    private void off() {
        light.off();
        tv.off();
        airCondition.off();
    }
}
